//
// Created by root on 4/29/17.
//

#include "../runner_scheme.h"

#define OP_MAKE_BOOLEAN(bool) Cell* b = make_integer(global_scheme, bool); \
    global_scheme->args = cons(global_scheme, b, &g_nil); \
    op_make_boolean(global_scheme); \
    Cell* r = global_scheme->returnValue

static void test_op_make_boolean_true() {
    OP_MAKE_BOOLEAN(1);
    assert_ptr_equal(r, &g_true);
}

static void test_op_make_boolean_false() {
    OP_MAKE_BOOLEAN(0);
    assert_ptr_equal(r, &g_false);
}

static void test_op_make_boolean_failure() {
    OP_MAKE_BOOLEAN(100);
    assert_string_equal(r->_type, EXCEPTION_TYPE);
    assert_string_equal(car(r)->_string, "NOT_A_BOOLEAN");
}

int main(int argc, char **argv) {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test(test_op_make_boolean_true),
            cmocka_unit_test(test_op_make_boolean_false),
            cmocka_unit_test(test_op_make_boolean_failure),
    };
    return cmocka_run_group_tests(tests, setup_scheme, teardown_scheme);
}
